package com.example.agent_intelligent_companion;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;

public class AICDatabase extends SQLiteOpenHelper{

	private static final String LOGTAG = "EXPLORECA";
	// tables in the database
	private static final String DATABASE_TABLE = "users";
	private static final String KEY_ROWID = "row_id";
	private static final String MAC_ADDRESS = "mac_address";
	private static final String LOCATION = "location";
	
	// Information about the database
	private static final String DATABASE_NAME = "AIC_DB";
	private static final int DATABASE_VERSION = 2;
	
	private static final String TABLE_CREATE = "CREATE TABLE " + DATABASE_TABLE + " ( " +
			KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
			MAC_ADDRESS + " TEXT, " +
			LOCATION + " TEXT ) ";
	private Context context;
	
	public AICDatabase(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		this.context = context;
	}

	
//	@SuppressLint("NewApi")
//	public AICDatabase(Context context, String name, CursorFactory factory,
//			int version, DatabaseErrorHandler errorHandler) {
//		super(context, name, factory, version, errorHandler);
//		// TODO Auto-generated constructor stub
//	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(TABLE_CREATE);
		Log.i(LOGTAG, "Table has been created");
		//db.execSQL("INSERT INTO " + DATABASE_NAME + "." + DATABASE_TABLE + "(" + KEY_ROWID + "," + MAC_ADDRESS + "," + LOCATION + ")" +
		//"VALUES(1,18:9E:FC:91:27:44,Boston)");
		Toast.makeText(context, "In OnCreate", 0).show();
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
	
	public void TestCall()
	{
		Toast.makeText(this.context, "Made it to DB" , 0).show();
	}

}
